﻿#region Copyright

// /*
// SilverlightInEnterprise
// SilverlightInEnterprise.Common
// RibbonTool.cs
// 
// Author: Matt Van Horn
// Created 11/15/2011 6:30 PM
// Copyright: Silverlight in the Enterprise www.slinenterprise.com
// 
// Licensed under MS-PL http://www.opensource.org/licenses/MS-PL and while you 
// may use this in anyway you see fit and owe us nothing to do so, we wouldn't mind knowing that you got value out of the work we did (so we will do more) so 
// we ask that you leave a comment on www.slinenterprise.com or on the codeplex site slinenterprise.codeplex.com
// 
// */

#endregion

using System;
using System.Windows.Input;
using Infragistics.Controls.Menus;
using SilverlightInEnterprise.Common.Events;
using SilverlightInEnterprise.Common.ViewModels;
using SilverlightInEnterprise.Interfaces.Ribbon;
using IGRibbonTool = Infragistics.Controls.Menus.RibbonTool;

namespace SilverlightInEnterprise.Common.Ribbon
{
    public abstract class RibbonTool : RibbonItem, IRibbonTool
    {
        private IGRibbonTool tool;

        public IGRibbonTool Tool
        {
            get
            {
                if (this.tool == null)
                    this.tool = new ButtonTool()
                                    {
                                        Caption = this.DisplayName,
                                        SmallImage = this.SmallImage,
                                        LargeImage = this.BigImage
                                    };
                return this.tool;
            }
        }

        public RibbonTool()

        {
            this._Command = new GenericCommand(this.Invoke);
        }

        private static OpenScreenEvent openScreenEvent;

        protected OpenScreenEvent OpenScreen
        {
            get
            {
                if (openScreenEvent == null)
                    openScreenEvent = this.Locator.CompositionProvider.GetExportedValue<OpenScreenEvent>();
                return openScreenEvent;
            }
        }

        #region BigImage Property

        private Uri _BigImage;

        public Uri BigImage
        {
            get { return this._BigImage; }
            set
            {
                if (this._BigImage != value)
                {
                    this._BigImage = value;
                    this.OnPropertyChanged("BigImage");
                }
            }
        }

        #endregion

        #region SmallImage Property

        private Uri _SmallImage;

        public Uri SmallImage
        {
            get { return this._SmallImage; }
            set
            {
                if (this._SmallImage != value)
                {
                    this._SmallImage = value;
                    this.OnPropertyChanged("SmallImage");
                }
            }
        }

        #endregion

        private readonly ICommand _Command;

        public ICommand Command
        {
            get { return this._Command; }
        }

        protected override void PopulateChildren()
        {
            throw new System.NotImplementedException();
        }


        public abstract void Invoke(object arg);
    }
}